package com.sh.ndt.common;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import org.apache.log4j.Logger;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;

@ManagedBean
@RequestScoped
public class CommonEmail {
	private MailSender mailSender;
	private static final Logger LOGGER = Logger.getLogger(CommonEmail.class);
	public CommonEmail(){
		LOGGER.debug("^^^^^^^^^^ Inside CommonEmail Constructor ^^^^^^^^^^");
	}
	public void setMailSender(MailSender mailSender) {
		this.mailSender = mailSender;
	}
 
	public void sendMail(String from, String to, String subject, String msg) {
 
		SimpleMailMessage message = new SimpleMailMessage();
 
		message.setFrom(from);
		message.setTo(to);
		message.setSubject(subject);
		message.setText(msg);
		mailSender.send(message);	
                
	}
}
